package com.ruoyi.InboundManagement.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.InboundManagement.domain.TransferInbound;
import com.ruoyi.InboundManagement.service.ITransferInboundService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 调拨入库管理Controller
 * 
 * @author admin
 * @date 2024-07-03
 */
@RestController
@RequestMapping("/InboundManagement/transferInbound")
public class TransferInboundController extends BaseController
{
    @Autowired
    private ITransferInboundService transferInboundService;

    /**
     * 查询调拨入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:list')")
    @GetMapping("/list")
    public TableDataInfo list(TransferInbound transferInbound)
    {
        startPage();
        List<TransferInbound> list = transferInboundService.selectTransferInboundList(transferInbound);
        return getDataTable(list);
    }

    /**
     * 导出调拨入库管理列表
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:export')")
    @Log(title = "调拨入库管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TransferInbound transferInbound)
    {
        List<TransferInbound> list = transferInboundService.selectTransferInboundList(transferInbound);
        ExcelUtil<TransferInbound> util = new ExcelUtil<TransferInbound>(TransferInbound.class);
        util.exportExcel(response, list, "调拨入库管理数据");
    }

    /**
     * 获取调拨入库管理详细信息
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:query')")
    @GetMapping(value = "/{transferId}")
    public AjaxResult getInfo(@PathVariable("transferId") Long transferId)
    {
        return success(transferInboundService.selectTransferInboundByTransferId(transferId));
    }

    /**
     * 新增调拨入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:add')")
    @Log(title = "调拨入库管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TransferInbound transferInbound)
    {
        return toAjax(transferInboundService.insertTransferInbound(transferInbound));
    }

    /**
     * 修改调拨入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:edit')")
    @Log(title = "调拨入库管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TransferInbound transferInbound)
    {
        return toAjax(transferInboundService.updateTransferInbound(transferInbound));
    }

    /**
     * 删除调拨入库管理
     */
    @PreAuthorize("@ss.hasPermi('InboundManagement:transferInbound:remove')")
    @Log(title = "调拨入库管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{transferIds}")
    public AjaxResult remove(@PathVariable Long[] transferIds)
    {
        return toAjax(transferInboundService.deleteTransferInboundByTransferIds(transferIds));
    }
}
